<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>注册</title>
	<style type="text/css">
	form {
		margin-top: 100px;

	}
	</style>
	<link rel="stylesheet" href= "./Tpl/css/bootstrap.min.css">
</head>
<body>
	<form class="form-horizontal">
		 <div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">用户名</label>
		    <div class="col-sm-3">
		      <input type="text" class="form-control" id="username" placeholder="用户名" name="username">
		    </div>
		    <p class="info"></p>
		 </div>		
		 <div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
		    <div class="col-sm-3">
		      <input type="text" name="email" class="form-control" id="email" placeholder="Email">
		    </div>
		    <p class="mail"></p>
		    <p class="info"></p>
		  </div>
		  <div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">密码</label>
		    <div class="col-sm-3">
		      <input type="email" name="password" class="form-control" id="password" placeholder="password">
		    </div>
		    <p class="password"></p>
		    <p class="mail"></p>
		    <p class="info"></p>
		  </div>
		  <div class="form-group">
		    <label for="inputPassword3" class="col-sm-2 control-label">确认密码</label>
		    <div class="col-sm-3">
		      <input type="password" name="passwords" class="form-control" id="inputPassword3" placeholder="Password">
		    </div>
		     <p class="password"></p>
		    <p class="mail"></p>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-4">
		      <div class="checkbox">
		        <label>
		          <input type="checkbox">记住密码
		        </label>
		      </div>
		      <p class="password"></p>
		    </div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		     <a href=""  class="btn btn-success">注册</a>
		    </div>
		 </div>
	</form>
	<script type="text/javascript" src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js">
	</script>
	<script type="text/javascript">


					
	$(function(){     //用户名
		$('#username').blur(function(event) {
			username=$(this).val();    //val是获取这个文本框的值，赋给username;
			$objUser=$(this);          //用一个变量把$this存起来，就是存了前面的那个username=$(this).val()，也就是文本框里面的值;
			$.ajax({
				url: './checkReg.php',
				type: 'post',
				dataType: 'json',
				data: {username: username},  //前面的username是他的下标，后面是一个变量
			})
			.done(function(shuju) {
				if(shuju.error==1){//html里面的值就是返回括号里面的（内容）；
					$objUser.parent().siblings('.info').html('<span class="glyphicon glyphicon-remove" style="color:red" aria-hidden="true"></span>'+shuju.info);
				}else{
					$objUser.parent().siblings('.info').html('<span class="glyphicon glyphicon-ok" style="color:blue" aria-hidden="true"></span>'+shuju.info);
				}

			})
			.fail(function(shuju) {
				$objUser.parent().siblings('.info').html('<span class="glyphicon glyphicon-remove" style="color:red" aria-hidden="true"></span>'+shuju.info);
			})
			
		});



	})

	</script>

									
<script type="text/javascript"> 

	$(function(){   //email 
		$('#email').blur(function(event) {
			
			email = $(this).val();
			$objmail=$(this);

			$.ajax({
				url: './email.php',
				type: 'post',
				dataType: 'json',
				data: {email: email},
			})
			.done(function(data) {
				if(data.error==1){
					$objmail.parent().siblings('.mail').html('<span class="glyphicon glyphicon-remove" style="color:red" aria-hidden="true"></span>'+data.mail);
				}else{
					$objmail.parent().siblings('.mail').html('<span class="glyphicon glyphicon-ok" style="color:blue" aria-hidden="true"></span>'+data.mail);
				}
			})
			.fail(function(data) {
				$objmail.parent().siblings('.mail').html('<span class="glyphicon glyphicon-remove" style="color:red" aria-hidden="true"></span>'+data.mail);
			});
		});
	})

</script>

<script type="text/javascript">
	$(function(){  //密码
		$('#password').blur(function(event) {
			password=$(this).val();
			$objpass=$(this);
		
		$.ajax({
			url: './mima.php',
			type: 'post',
			dataType: ' json',
			data: {password: 'password'},
		})
		.done(function() {
			alert('你对了');
		})
		.fail(function() {
			alert('你错啦');
		})
		
		
	});




})





</script>



	
</body>
</html>